package DailyPractice.Day23;

import java.util.Scanner;

/**
 * @author lumin
 * @date 2022/05/19 19:30
 **/
public class Num2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.nextLine();
        String str2 = sc.nextLine();
        int[][] arr = new int[str1.length()][str2.length()];
        int count = 0;
        int i = 0;
        while(i < arr.length){
            int j = 0;
            while(j < arr[0].length){
                if(i == 0){
                    if(j == 0){
                        if(str1.charAt(i) == str2.charAt(j)){
                            arr[0][0] = 0;
                        }else{
                            arr[0][0] = 1;
                        }
                    }else{
                        arr[i][j] = arr[i][j - 1] + 1;
                    }
                }else{
                    if(j == 0){
                        arr[i][j] = arr[i - 1][j] + 1;
                    }else{
                        if(str1.charAt(i) == str2.charAt(j)){
                            arr[i][j] = arr[i - 1][j - 1];
                        }else{
                            arr[i][j] = 1 + Math.min(arr[i][j - 1],arr[i - 1][j]);
                        }
                    }
                }
                j++;
            }
            i++;
        }
        System.out.println(arr[str1.length() - 1][str2.length() - 1]);
    }
}